class Solution {
public:
	bool _isValidSudoku(vector<vector<char>>& board, int row, int col)
	{
		vector<bool> repeat(10, false);
		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				if (board[row + i][col + j] == '.')
					continue;
				if (repeat[board[row + i][col + j] - '0'])
					return false;
				else
					repeat[board[row + i][col + j] - '0'] = true;
			}
		}
		return true;
	}

	bool isValidSudoku(vector<vector<char>>& board) {
		for (int i = 0; i < 9; i++)
		{
			vector<bool> repeat(10, false);
			for (int j = 0; j < 9; j++)
			{
				if (board[i][j] == '.')
					continue;
				if (repeat[board[i][j] - '0'])
					return false;
				else
					repeat[board[i][j] - '0'] = true;
			}
		}

		for (int i = 0; i < 9; i++)
		{
			vector<bool> repeat(10, false);
			for (int j = 0; j < 9; j++)
			{
				if (board[j][i] == '.')
					continue;
				if (repeat[board[j][i] - '0'])
					return false;
				else
					repeat[board[j][i] - '0'] = true;
			}
		}

		for (int i = 0; i < 9; i += 3)
		{
			for (int j = 0; j < 9; j += 3)
			{
				if (!_isValidSudoku(board, i, j))
					return false;
			}
		}
		return true;
	}
};